#include <bits/stdc++.h>

using namespace std;

struct P{
    int x,y;
    const bool operator < (const P &p) const{return x<p.x||(x==p.x&&y<p.y);}
};

const int maxn=200005;
int xs[maxn],ys[maxn];
int tot[maxn],sum[maxn],mx;
int ans,n;
P pts[maxn];

inline int lowbit(const int &x){return x&(-x);}

inline void inc(int x){for(;x<=mx;x+=lowbit(x)) sum[x]++;}
inline int cnt(int x){int ans=0;for(;x>0;x-=lowbit(x)) ans+=sum[x];return ans;}

void solve();

inline int read(){
    int r;char c;bool f=0;
    for(c=getchar();c>'9'||c<'0';c=getchar()) if(c=='-') f=1;
    for(r=0;c<='9'&&c>='0';c=getchar()) r=r*10+c-'0';
    if(f) return -r;
    else return r;
}

int main(){
    n=read();
    for(int i=0;i<n;i++){
        pts[i].x=xs[i]=read();pts[i].y=ys[i]=read();
    }
    sort(xs,xs+n);
    for(int i=0;i<n;i++) pts[i].x=2*(lower_bound(xs,xs+n,pts[i].x)-xs)+1;
    sort(ys,ys+n);
    for(int i=0;i<n;i++) pts[i].y=2*(lower_bound(ys,ys+n,pts[i].y)-ys)+1;
    sort(pts,pts+n);

    mx=2*n-1;
    memset(sum,0,sizeof sum);
    memset(tot,0,sizeof tot);
    for(int i=0;i<n;i++) tot[pts[i].y]++;
    for(int i=1;i<=mx;i++) tot[i]+=tot[i-1];
    ans=n;
    for(int i=0;i<n;i++){
        inc(pts[i].y);
        if(pts[i].x==pts[i+1].x) continue;
        solve();
    }

    printf("%d\n",ans);
}

void solve(){
    int l=1,r=mx;
    while(l<r){
        int mid=(l+r)>>1;
        int t1=cnt(mid);
        int t2=tot[mid]-t1;
        int t3=cnt(mx)-t1;
        int t4=n-t1-t2-t3;
        //assert(t1+t2+t3+t4==n);
        ans=min(ans,max(max(t1,t2),max(t3,t4)));
        if(max(t1,t2)>max(t3,t4)) r=mid;
        else l=mid+1;
    }
}
